<template>
    <view class="main">
        <Empty v-if="!jobListData.length" text="暂无收藏的职位" />
        <jobCard :type="2" :data="jobListData" v-else />
        <!-- <LoadMore :status="status" :show="loadShow" /> -->
    </view>
</template>

<script setup lang="ts">
import jobCard from '@/components/jobCard/jobCard.vue';
import { getCollectJob } from '@/api/home/home'
import type { RequestMyCommentType } from '@/types/requstParm'
import type { JobObjectDataType } from '@/types/responseData'
import { onPullDownRefresh, onReachBottom } from '@dcloudio/uni-app';
import { reactive, ref, onMounted } from 'vue';


let queryData = reactive<RequestMyCommentType>({
    user_id: 2,
    page: 1,
    limit: 10,
})

const status = ref<string>('loadmore')
const loadShow = ref<boolean>(false)
let jobListData = ref<Array<JobObjectDataType>>([])
const getListData = async () => {
    status.value = 'loading'
    const res = await getCollectJob(queryData)
    if (res.code == 0) {
        if (res.data.list.length) {
            status.value = 'loadmore'
            loadShow.value = true
            jobListData.value = [...jobListData.value, ...res.data.list]
        } else {
            loadShow.value = true
            status.value = 'nomore'
        }
    }
}
const init = () => {
    jobListData.value = []
    queryData.page = 1
}

onReachBottom(() => {
    (queryData.page as number)++
    getListData()
})

onPullDownRefresh(async () => {
    uni.showLoading()
    init()
    await getListData()
    uni.stopPullDownRefresh()
    uni.hideLoading()
})

onMounted(() => {
    getListData()
})
</script>
<style lang="scss" scoped>
.main {
    padding: 30rpx;
}
</style>